package com.chb.demo.controller;

import com.chb.demo.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.Map;

@Controller
public class LoginController {



    @Autowired
    LoginService loginService;

    @RequestMapping("/loginchecker")
    @ResponseBody
    public Object login(@RequestParam("account") String account, @RequestParam("password") String password,HttpSession session){
        System.out.println("发请求");
        System.out.println(account+password);

        Map<String, Object> map = loginService.loginValid(account,password);

        session.setAttribute("map",map);


        System.out.println(map.get("success"));
        return map;
    }

}
